package com.bwie.parkdemo.mvvm.model;

import android.content.Context;

import com.bwie.lib_core.base.BaseEntity;
import com.bwie.lib_core.mvvm.base.BaseModel;
import com.bwie.lib_core.network.HttpRetrofitFactory;
import com.bwie.lib_core.network.HttpType;
import com.bwie.parkdemo.dao.LoginUserServe;
import com.bwie.parkdemo.mvvm.model.entity.VisitorDelEntity;
import com.bwie.parkdemo.mvvm.model.entity.VisitorEntity;

import io.reactivex.Observable;
import okhttp3.RequestBody;

/**
 * model层:查询全部来访预约列表界面model
 * */
public class SelVisitorModel extends BaseModel {

    //获取全部列表请求使用
    @Override
    public Observable<BaseEntity> request(RequestBody... bodyes) {
        Observable<VisitorEntity>selVisitorOB = HttpRetrofitFactory.getInstance()
                .factory(HttpType.TOKENINTERFACE).getRetrofit().create(Api.class)
                .requestSelVisitor(bodyes[0]);
        return changeOB(selVisitorOB);
    }

    //删除数据接口
    public Observable<BaseEntity> requestDelVisitor(RequestBody body){
        return HttpRetrofitFactory.getInstance().
                factory(HttpType.TOKENINTERFACE)
                .getRetrofit().create(Api.class).requestDelVisitor(body);
    }

    public int requestUserId(Context ctx){
        return new LoginUserServe(ctx).selUser().uId;
    }

    @Override
    public void cleared() {

    }
}
